package diveplanner;

import static org.junit.Assert.*;

import org.junit.Test;

public class DiveTableTest {
	
	/**
	 * Testing the maxTimeAllowed() method
	 * 
	 * This method doesn't require much testing, since it has to return static values.
	 */
	@Test
	public void maxTimeAllowedTest()  {
		DiveTable table = new DiveTable();
		
		//mini-loops can handle multiple cases in a short amount of time?
		
		assertEquals("Less than 0 should return -1", -1, table.maxTimeAllowed(-5) );
		assertEquals("0 should return -1 as error", -1, table.maxTimeAllowed(0) );
		
		//anything between 1 and 10 should return as if it were 10 meters
		for(int i = 1; i < 10; i++)  {
			assertEquals("1 through 10 should return 219", 219, table.maxTimeAllowed(i) );
		}		
		
		assertEquals("11 should return 147", 147, table.maxTimeAllowed(11) );
		assertEquals("12 should return 147", 147, table.maxTimeAllowed(12) );
		
		assertEquals("13 should return 98", 98, table.maxTimeAllowed(13) );
		assertEquals("14 should return 98", 98, table.maxTimeAllowed(14) );
		
		assertEquals("15 should return 72", 72, table.maxTimeAllowed(15) );
		assertEquals("16 should return 72", 72, table.maxTimeAllowed(16) );
		
		assertEquals("17 should return 56", 56, table.maxTimeAllowed(17) );
		assertEquals("18 should return 56", 56, table.maxTimeAllowed(18) );
		
		assertEquals("19 should return 45", 45, table.maxTimeAllowed(19) );
		assertEquals("20 should return 45", 45, table.maxTimeAllowed(20) );
		
		assertEquals("21 should return 37", 37, table.maxTimeAllowed(21) );
		assertEquals("22 should return 37", 37, table.maxTimeAllowed(22) );
		
		assertEquals("23 should return 29", 29, table.maxTimeAllowed(23) );
		assertEquals("24 should return 29", 29, table.maxTimeAllowed(24) );
		assertEquals("25 should return 29", 29, table.maxTimeAllowed(25) );
		
		assertEquals("26 should return 20", 20, table.maxTimeAllowed(26) );
		assertEquals("27 should return 20", 20, table.maxTimeAllowed(27) );
		
		//Besides testing exact values, try testing edge cases, such as the boundaries of short/int values
		

	}
	
	/**
	 * Testing the residualNitro() method
	 * 
	 * 
	 */
	
	@Test
	public void residualNitroTest()  {
		DiveTable table = new DiveTable();
		
		assertEquals("All values are -1, should return -1", -1, table.residualNitro(-1, -1, -1, -1, -1) );
		
		assertEquals("This should return 0", 0, table.residualNitro(10, 10, 181, 20, 0) );
		assertEquals("This should return 6", 6, table.residualNitro(10, 10, 179, 20, 0) );
		assertEquals("This should return -1", -1, table.residualNitro(11, 147, 1, 10, 0) );
		assertEquals("This should return -1", -1, table.residualNitro(11, 134, 1, 10, 1) );
		assertEquals("This should return 199", 199, table.residualNitro(11, 132, 2, 10, 1) );
		assertEquals("This should return 134", 134, table.residualNitro(11, 132, 2, 12, 1) );
		assertEquals("This should return 92", 92, table.residualNitro(14, 89, 0, 14, 2) );
		assertEquals("This should return 30", 30, table.residualNitro(20, 30, 4, 20, 0) );
		assertEquals("This should return 0", 0, table.residualNitro(20, 30, 316, 20, 0) );
		assertEquals("This should return -1", -1, table.residualNitro(25, 13, 25, 40, 5) );
		assertEquals("This should return -1", -1, table.residualNitro(25, 13, 25, 0, 5) );
		assertEquals("This should return -1", -1, table.residualNitro(26, 13, 25, 35, 5) );
		
	}

}
